using System.Collections;
using System.Collections.Generic;
using OrderSystem;
using PureMVC.Interfaces;
using PureMVC.Patterns;
using UnityEngine;

/// <summary>
/// 订单获取与取消命令类，负责处理订单的创建和移除相关业务逻辑
/// 继承自PureMVC的SimpleCommand，协调订单代理和菜单代理完成订单管理
/// </summary>
public class GetAndExitOrderCommed : SimpleCommand
{
    /// <summary>
    /// 执行命令，根据通知类型处理订单获取或取消操作
    /// </summary>
    /// <param name="notification">包含客户信息的通知对象，Type属性指定操作类型：
    /// - "Get": 获取订单，创建新订单并添加到系统
    /// - "Exit": 取消订单，从系统中移除订单
    /// </param>
    public override void Execute(INotification notification)
    {
        OrderProxy orderProxy = PureMVC.Patterns.Facade.Instance.RetrieveProxy("OrderProxy") as OrderProxy;
        MenuProxy menuProxy = PureMVC.Patterns.Facade.Instance.RetrieveProxy("MenuProxy") as MenuProxy;
       // WaiterProxy waiterProxy = PureMVC.Patterns.Facade.Instance.RetrieveProxy("WaiterProxy") as WaiterProxy;
        if (notification.Type =="Get")
        {
            Order order = new Order(notification.Body as ClientItem,menuProxy.Menus);
            orderProxy.AddOrder(order);
            SendNotification(OrderSystemEvent.UPMENU, order);
           // waiterProxy.ChangeWaiter();//上菜改变服务员的属性
        }
        else if (notification.Type =="Exit") //删除菜单 
        {
            Order order = new Order(notification.Body as ClientItem, menuProxy.Menus);
            orderProxy.RemoveOrder(order); 
        }
    }
}
